﻿/**
 * @brief ParaSolid模型基类
 * @author BaGuijun (baguijun@163.com)
 * @date 2024-08-01
 */
#ifndef _FITKAbstractPSModel_H__
#define _FITKAbstractPSModel_H__

#include "FITKGeoCompPSAPI.h"
#include "FITK_Interface/FITKInterfaceGeometry/FITKAbsGeoCommand.h"
#include "FITK_Interface/FITKInterfaceGeometry/FITKAbsGeoShapeAgent.h"

class QTextStream;
class QVector3D;

namespace PS
{
    class FITKGeoComponentManager;

    /**
     * @brief ParaSolid模型
     * @author BaGuijun (baguijun@163.com)
     * @date 2024-08-01
     */
    class FITKGeoCompPSAPI FITKAbstractPSModel : public Interface::FITKAbsGeoShapeAgent
    {
        FITKCLASS(PS, FITKAbstractPSModel);
    public:
        /**
         * @brief Construct a new FITKAbstractPSModel object
         * @param[i]  command        My Param doc
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-08-01
         */
        explicit FITKAbstractPSModel(Interface::FITKAbsGeoCommand* command);
        /**
         * @brief Destroy the FITKAbstractPSModel object
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-08-01
         */
        virtual ~FITKAbstractPSModel();
        /**
         * @brief 写出模型到文件
         * @param[i]  file           文件绝对路径（包含文件名）
         * @return true   写出成功
         * @return false  写出失败
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-08-01
         */
        virtual bool writeToFile(const QString & file);
        /**
         * @brief 获取形状的数量
         * @param type 形状类别
         * @return int 返回指定形状的数量，错误时返回-1
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-08-01
         */
        int getShapeCount(const Interface::FITKModelEnum::FITKModelSetType type) override;
        /**
       * @brief 获取几何引擎类型
       * @return FITKGeoEnum::FITKGeoEngine
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-08-01
       */
        Interface::FITKGeoEnum::FITKGeoEngine getGeoEngine() override;
        /**
        * @brief 获取模型类型
        * @return AbsModelType
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-08-01
        */
        Interface::FITKModelEnum::AbsModelType getAbsModelType() override;
        /**
         * @brief   写出STL文件。
         * @param   folderPath：文件写出所在文件夹
         * @return  是否成功写出
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-08-01
         */
        bool writeSTLFile(QString folderPath) override;
        /**
         * @brief 获取模型包围盒
         * @param[o] minPt 最小点位置
         * @param[o] maxPt 最大点位置
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-08-01
         */
        void getBoundaryBox(double* min, double* max) override;
        /**
         * @brief 更新形状
         * @param[i] shape 形状对象
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-08-01
         */
        void updateShape(int shape);
    protected:
        /**
         * @brief   三角面片化
         * @param   shape：形状数据[引用]
         * @param   factor：网格划分精密度因子（与形状尺寸搭配使用）[缺省]
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-08-01
         */
        void triangulate(const int shape, double factor = 0.001);
    protected:
        /**
         * @brief 模型数据
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-08-01
         */
        int _shape = -1;
    };

    class PSShapeAgent
    {
    public:
        explicit PSShapeAgent(Interface::FITKAbsGeoCommand* c);
        virtual ~PSShapeAgent() = default;

    protected:
        FITKAbstractPSModel* _paraSolidShapeAgent{};
    };

}


#endif
